package com.mobile.android.connectionmanager;

import android.content.Context;
import android.net.ConnectivityManager;

public class ConnectionManager {
	 /**
     * Checks whether the device is able to connect to the network
     * @param context
     * @return
     */
    public static boolean isNetworkAvailable( Context context ) {
    	boolean resp = false;

        try {
			final ConnectivityManager connMgr = (ConnectivityManager)context.getSystemService(
												Context.CONNECTIVITY_SERVICE);
            final android.net.NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
            final android.net.NetworkInfo mobile = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
			
            if ( mobile.isAvailable() || wifi.isAvailable() ) {                
                    resp = true;
            }

        } catch ( Exception e ) {
            e.printStackTrace();
        }

        return resp;
    }
}
